import axios from 'axios';
import React, { useEffect } from 'react';
import { useHistory } from 'react-router-dom';
import { mobileLogin } from '../../utils/api/login';
import './index.css';
const mobile = '13795274470', pwd = 'Xnqpfwyd5';
const LoginPage = ({ }) => {
    let history = useHistory();
    useEffect(() => {
        
    }, []);
    function login() {
        axios.get(mobileLogin(mobile, pwd)).then(res => {
            console.log(res.data);
            let d = res.data;
            switch (d.code) {
                case 200:
                    localStorage.setItem("TOKEN", res.data.token);
                    localStorage.setItem("PROFILE", JSON.stringify(res.data.profile));
                    history.push('/main/finding');
                    break;
                case 502:
                    console.log(d.message);
                    break;
                default:
                    break;
            }
        })
    }
    return (
        <div className="login-container">
            <div className="logo-container">
                <div className="position-wrapper" >
                    <img className="logo" src="./imgs/logo.jpg"/>
                </div>
                <div className="position-wrapper" >
                    <div className="circle wave"></div>
                </div>  
            </div>
            <div className="operation-pad">
                <div className="mobile-area">
                    13795274470
                </div>
                <span>中国移动提供认证服务</span>
                <div className="login-btn" onClick={() => login()}>
                    一键登录
                </div>
                <div className="login-btn experience" onClick={() => login()}>
                    立即体验
                </div>
                <span>登录即已同意《服务条款》《隐私政策》《儿童隐私政策》</span>
                <span>《中国移动认证服务协议》</span>
            </div>
        </div>
    )
}

export default LoginPage;